#include "StdAfx.h"
#include "GamePart.h"
#include "GMM_AttachActorTo.h"
#include "GMM_DetachActorFrom.h"

namespace _DATAPART_
{
	namespace _GAME_
	{
		FoImplementRTTI(GamePart,_FOGGE_::_GDB_::aDataPartBase);

		GamePart::GamePart(void)
			:_FOGGE_::_GDB_::aDataPartBase(_FOGGE_::eEMID_Game)
		{
			m_fAccumedTime=0;
			m_ptrParent=NULL;
		}
		GamePart::~GamePart(void)
		{
		}
		void GamePart::SetParent(GamePart* ptrParent)
		{
			if(m_ptrParent)
			{//remove job here!!

			}
			ptrParent->m_listChild.push_back(this);
			m_ptrParent=ptrParent;
			
		}
		GamePart* GamePart::AttachPart(GamePart* ptrPart)
		{
			// send attatchment info
			_GMMSG::GMM_AttachActorTo* ptrAA=
				FoDynamicCast(_GMMSG::GMM_AttachActorTo,GetNewMassage(_GMMSG::eGMM_AttachActorTo));

			ptrPart->SetParent(this);

			ptrAA->m_ptrDataAttachBase=GetOwner();
			ptrAA->m_ptrDataToAttach=ptrPart->GetOwner();

			
			BroadcastMessage(ptrAA);

			return NULL;
		}

		void GamePart::SetDesiredLocation(const _FOMATH::Vector& newloc)
		{
			SetLocation(newloc);
			
		}
		void GamePart::SetDesiredRotation(const _FOMATH::Rotator& newrot)
		{
			SetRotation(newrot);
		}
		
	}
}

namespace _DATAPARTFACTORY_
{
	namespace _GAME_
	{
		GamePartFactory::GamePartFactory(void)
		{
			__super::m_Name="GamePart";
		}
		GamePartFactory::~GamePartFactory(void)
		{
		}

		_FOGGE_::_GDB_::aDataPartBase* GamePartFactory::GetNewPart()
		{
			return NULL;
		}

		_FOGGE_::_GDB_::aDataPartBase* GamePartFactory::LoadPart(TiXmlNode* ptrNode)
		{
			return NULL;
		}
			
		_FOGGE_::_GDB_::aDataPartBase* GamePartFactory::CreatePart()
		{
			return NULL;
		}
	}
}
	
